package com.shxzz.easy12306.services.ticket.service.handler.filter.query;

import cn.hutool.core.text.CharSequenceUtil;
import com.shxzz.easy12306.framework.starter.convention.exceptions.ClientException;
import com.shxzz.easy12306.services.ticket.dto.req.TicketPageQueryReqDTO;
import org.springframework.stereotype.Component;

/**
 * 车票查询参数不为空校验
 * @author shxzz
 * @create 2024-03-06-13:59
 */
@Component
public class TicketSearchParamNotNullChainFilter implements TicketSearchChainFilter{

    @Override
    public void handler(TicketPageQueryReqDTO requestParam) {
        if (CharSequenceUtil.isBlank(requestParam.getFromStation())) {
            throw new ClientException("出发地不能为空");
        }
        if (CharSequenceUtil.isBlank(requestParam.getToStation())) {
            throw new ClientException("目的地不能为空");
        }
        if (requestParam.getDepartureDate() == null) {
            throw new ClientException("出发日期不能为空");
        }
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
